1 00:00:00,110 --> 00:00:03,720 Now we're in our battle royale arena and there's nothing in it. 2 00:00:03,740 --> 00:00:04,760 That's fine. 3 00:00:04,760 --> 00:00:07,880 I'll let you guys decorate this map however you want. 4 00:00:07,910 --> 00:00:12,100 You know, pipes and buildings and cars and stuff that you can hide behind. 5 00:00:12,110 --> 00:00:16,610 But what we need to do is think about the mechanics of when they teleport over. 6 00:00:16,610 --> 00:00:20,710 So we don't want them all going to the same spawn location. 7 00:00:20,720 --> 00:00:25,810 We'll do a control D You might want to spread these out kind of far on the map. 8 00:00:25,820 --> 00:00:33,230 I'm just going to put four here, but they're still going to be chance that they could land together 9 00:00:33,260 --> 00:00:35,240 on the spawn location. 10 00:00:35,240 --> 00:00:42,440 What we should do is give a buffer time like eight seconds or people can run off and they don't have 11 00:00:42,440 --> 00:00:44,090 weapons and they can't attack. 12 00:00:44,090 --> 00:00:46,490 So let's go ahead and work on that right now. 13 00:00:48,250 --> 00:00:50,800 Let's go down to server script service. 14 00:00:50,830 --> 00:00:55,420 Take a look at the game manager, the script that we we copied in. 15 00:00:56,210 --> 00:01:03,060 Now, our game manager actually equips our player, but it uses the equipment manager to do it. 16 00:01:03,080 --> 00:01:08,180 I'm going to scroll down here to this player added, I have two extra spaces. 17 00:01:08,180 --> 00:01:10,400 You probably don't have these spaces here. 18 00:01:10,580 --> 00:01:11,780 We just fix that. 19 00:01:12,110 --> 00:01:19,280 And when the character is added to the game, our equipment manager equips the player. 20 00:01:19,310 --> 00:01:21,590 Let's just get rid of that line of code. 21 00:01:21,620 --> 00:01:23,090 Boom, gone. 22 00:01:23,090 --> 00:01:27,110 But we also did it down here. 23 00:01:27,560 --> 00:01:32,240 Let's get rid of that line of code just in case the character added event didn't fire quick enough. 24 00:01:32,720 --> 00:01:33,560 All right. 25 00:01:33,590 --> 00:01:38,300 Now let's go to our battle manager right here. 26 00:01:38,540 --> 00:01:43,640 Now in our battle manager, we want to require the equipment manager because that's when we want to 27 00:01:43,640 --> 00:01:44,990 put the weapons on our player. 28 00:01:44,990 --> 00:01:47,960 So let's go up near the top line three. 29 00:01:47,960 --> 00:01:52,520 I'll do a local equip, MGR. 30 00:01:52,550 --> 00:02:00,630 We're going to require game dot server script service equipment manager. 31 00:02:00,720 --> 00:02:04,710 Now we can equip them in our battle manager. 32 00:02:05,580 --> 00:02:11,970 And while we're here up at the top, don't forget we're going to have to send messages to some sort 33 00:02:11,970 --> 00:02:18,450 of user interface so people could start see when the battle's starting or if they want things like that. 34 00:02:18,450 --> 00:02:22,070 So let's go ahead and get a variable for replicated storage. 35 00:02:22,080 --> 00:02:30,150 I'll say game get service, replicated storage, and in replicated storage, we're going to have a remote 36 00:02:30,150 --> 00:02:36,660 event, I think we'll call it status R, A status E, We don't have it yet. 37 00:02:36,780 --> 00:02:39,720 We'll do await for child semicolon notice. 38 00:02:39,750 --> 00:02:41,010 We just have weapons here. 39 00:02:41,010 --> 00:02:42,180 Let's fix that. 40 00:02:42,180 --> 00:02:47,430 Let's go to replicated storage, hit the plus, add a remote event. 41 00:02:47,460 --> 00:02:56,100 Let's call that remote event status E Now when we go back here, boom. 42 00:02:56,280 --> 00:03:01,710 So the remote event is the gateway between the server and the client and the client and the server. 43 00:03:01,710 --> 00:03:07,320 So we can send messages to our client and we can get a sound going on the client side. 44 00:03:07,320 --> 00:03:09,780 We can get guys, stuff like that. 45 00:03:11,070 --> 00:03:13,260 Let's go down to lines. 46 00:03:13,620 --> 00:03:16,590 We'll make a function, local function. 47 00:03:16,590 --> 00:03:19,400 I'm just going to call this battle right? 48 00:03:19,410 --> 00:03:22,770 And battle is going to run for the entire battle. 49 00:03:22,770 --> 00:03:25,110 We're going to check statuses, things like that. 50 00:03:25,110 --> 00:03:31,560 But the first thing it's going to do is it count down, give people time to run when they have no weapons. 51 00:03:31,560 --> 00:03:36,440 So we'll say for I equals, we'll make it eight seconds, right? 52 00:03:36,510 --> 00:03:39,780 We could make these variables, we shouldn't use literals, but that's fine. 53 00:03:39,780 --> 00:03:40,460 For now. 54 00:03:40,470 --> 00:03:47,130 We'll say I equals eight, maybe go down to zero and then we're going to go in steps of minus one. 55 00:03:47,130 --> 00:03:52,950 We're going to go eight, seven, six, five four like that do we'll do our one second. 56 00:03:52,950 --> 00:03:53,610 Wait. 57 00:03:53,610 --> 00:03:58,350 And then for now, let's just print this out to the console so we know what's going on. 58 00:03:58,440 --> 00:04:10,430 We'll say battle starting in dot, dot, dot I comma seconds. 59 00:04:12,650 --> 00:04:13,760 Oops, seconds. 60 00:04:13,760 --> 00:04:14,480 There we go. 61 00:04:14,690 --> 00:04:15,320 All right. 62 00:04:15,360 --> 00:04:19,160 When we get down to that point, we're going to equip our player. 63 00:04:20,030 --> 00:04:23,360 So we'll do a for loop for all the players in the game. 64 00:04:23,360 --> 00:04:25,670 And we don't have the players variable. 65 00:04:25,670 --> 00:04:27,590 Let's add the players variable. 66 00:04:27,620 --> 00:04:29,210 Let's go to line six. 67 00:04:29,810 --> 00:04:33,560 Local players equals game. 68 00:04:33,560 --> 00:04:36,320 Get service players. 69 00:04:36,440 --> 00:04:37,160 All right. 70 00:04:37,190 --> 00:04:45,770 Now let's go back down to our battle function and I'll do a for loop for I and V in pairs. 71 00:04:46,610 --> 00:04:52,820 We'll get our players variable right and then we'll do get children to get all the players from the 72 00:04:52,820 --> 00:04:55,730 players variable and it's to the player service. 73 00:04:55,730 --> 00:04:57,290 That's what the variable is for. 74 00:04:57,470 --> 00:05:06,380 Just do this do We're going to get our equipment manager Colon and we'll just do equip player and pass 75 00:05:06,380 --> 00:05:06,980 in the player. 76 00:05:06,980 --> 00:05:10,580 But the player is actually V, right? 77 00:05:10,580 --> 00:05:12,270 So let's put a V there. 78 00:05:12,840 --> 00:05:13,800 There we go. 79 00:05:13,800 --> 00:05:16,470 So this is this I is one, two, three, four. 80 00:05:16,470 --> 00:05:19,920 If you have four players, this V is going to be the player. 81 00:05:20,580 --> 00:05:21,000 All right. 82 00:05:21,030 --> 00:05:21,300 Nice. 83 00:05:21,300 --> 00:05:23,220 So we don't want any weights in there. 84 00:05:23,220 --> 00:05:27,510 We want everybody to get their weapons at approximately the same time. 85 00:05:27,930 --> 00:05:30,510 Then we're going to do a status re to the client. 86 00:05:30,540 --> 00:05:31,770 Nothing's on the client side. 87 00:05:31,770 --> 00:05:38,310 We'll just put this in here as a placeholder and we'll fire all clients and then we're going to send 88 00:05:38,310 --> 00:05:38,910 a message. 89 00:05:38,910 --> 00:05:41,520 We'll just say, Begin now. 90 00:05:41,520 --> 00:05:43,380 We're not calling this battle yet. 91 00:05:43,410 --> 00:05:45,420 We have to do that or it won't work. 92 00:05:45,420 --> 00:05:46,920 Let's go down. 93 00:05:47,390 --> 00:05:54,500 Below the player added event because battle is going to run for the entire duration of the battle. 94 00:05:54,500 --> 00:05:56,180 It doesn't now, but it will. 95 00:05:56,180 --> 00:05:58,910 And we don't want to block our player added event. 96 00:05:58,940 --> 00:06:01,070 The connection to our event handler. 97 00:06:01,070 --> 00:06:06,350 So let's do battle right here and then we'll hit the play button. 98 00:06:06,350 --> 00:06:09,230 We can play it here because we're not actually doing the teleport. 99 00:06:09,230 --> 00:06:14,720 We're just this is where we would be teleporting into the game, right? 100 00:06:14,720 --> 00:06:15,800 So we're here. 101 00:06:15,800 --> 00:06:18,320 Let's go to our View. 102 00:06:19,200 --> 00:06:20,040 Output window. 103 00:06:20,040 --> 00:06:20,580 Here it is. 104 00:06:20,580 --> 00:06:23,070 The printout file starting in. 105 00:06:23,940 --> 00:06:24,810 Oh, look at that. 106 00:06:24,810 --> 00:06:26,640 And then we got our pistol. 107 00:06:26,670 --> 00:06:29,640 When this got down to zero. 108 00:06:29,670 --> 00:06:31,460 That's pretty cool. 109 00:06:31,470 --> 00:06:33,360 So now we have a grace period. 110 00:06:33,360 --> 00:06:37,110 You'd probably want it to be like 30 seconds, right? 111 00:06:37,110 --> 00:06:41,160 But eight seconds is great for a video because you don't want to have to wait that long.